/*!
 * # 参数列表实体类:
 *  List - 通知列表
 * 
 * # 描述:
 *  查询当前用户接收到的通知列表。
 *  
 *  Copyright (c), 上海沃恩信息科技有限公司.
 *  All rights reserved.
 *  Licensed under BSD (https://www.pittypat.work/bsd.html).
 */

using Pittypat;

namespace Waln.Notifying.Inbox.Args
{
	/// <summary>
	/// 功能 通知列表 的参数列表。
	/// </summary>
	[global::Pittypat.Function(Transaction = false)]
	public sealed class List : global::Pittypat.FunctionArgs
	{
		#region 构造函数

		/// <summary>
		/// 初始化 List 类的一个新实例。
		/// </summary>
		public List()
		{
			// 页码
			this.PageIndex = null;
			// 页面尺寸
			this.PageSize = null;
			// 总行数
			this.TotalRows = null;
			// 排序名称
			this.OrderName = null;
			// 排序方向
			this.OrderDirection = null;
			// 用户 Id
			this.UserId = null;
			// 通知标题
			this.Title = null;
			// 发送人名称
			this.SenderName = null;
			// 是否已读
			this.IsRead = null;
			// 紧急程度
			this.Urgency = null;
			// 分组
			this.Group = null;
			// 起始接收时间
			this.ReceiveTimeFrom = null;
			// 截至接收时间
			this.ReceiveTimeTo = null;
			// 是否包含置顶通知
			this.IncludesTop = null;
			// 未置顶通知列表
			this.Notifications = null;
			// 置顶通知列表
			this.TopNotifications = null;
		}

		#endregion

		#region 属性

		/// <summary>
		/// 获取或者设置页码。
		/// </summary>
		[global::Pittypat.Parameter(0, Role = global::Pittypat.ParameterRole.PageIndex)]
		public @int64? PageIndex { get; set; }

		/// <summary>
		/// 获取或者设置页面尺寸。
		/// </summary>
		[global::Pittypat.Parameter(1, Role = global::Pittypat.ParameterRole.PageSize)]
		public @int64? PageSize { get; set; }

		/// <summary>
		/// 获取或者设置总行数。
		/// </summary>
		[global::Pittypat.Parameter(2, Direction = global::Pittypat.ParameterDirection.Out, Role = global::Pittypat.ParameterRole.TotalRows)]
		public @int64? TotalRows { get; set; }

		/// <summary>
		/// 获取或者设置排序名称。
		/// </summary>
		[global::Pittypat.Parameter(3, Role = global::Pittypat.ParameterRole.OrderName, MaxLength = 30)]
		public @string? OrderName { get; set; }

		/// <summary>
		/// 获取或者设置排序方向。
		/// </summary>
		[global::Pittypat.Parameter(4, Role = global::Pittypat.ParameterRole.OrderDirection, MaxLength = 4)]
		public @string? OrderDirection { get; set; }

		/// <summary>
		/// 获取或者设置用户 Id。
		/// </summary>
		/// <remarks>
		/// 当前用户的 Id，由系统自动设置该参数。
		/// </remarks>
		[global::Pittypat.Parameter(5, Role = global::Pittypat.ParameterRole.UserId)]
		public @uuid? UserId { get; set; }

		/// <summary>
		/// 获取或者设置通知标题。
		/// </summary>
		/// <remarks>
		/// 通知的标题。
		/// </remarks>
		[global::Pittypat.Parameter(6, MaxLength = 50)]
		public @string? Title { get; set; }

		/// <summary>
		/// 获取或者设置发送人名称。
		/// </summary>
		/// <remarks>
		/// 消息发送人的名称。
		/// </remarks>
		[global::Pittypat.Parameter(7, MaxLength = 50)]
		public @string? SenderName { get; set; }

		/// <summary>
		/// 获取或者设置是否已读。
		/// </summary>
		/// <remarks>
		/// 查询已读或者未读的通知。
		/// </remarks>
		[global::Pittypat.Parameter(8)]
		public @bool? IsRead { get; set; }

		/// <summary>
		/// 获取或者设置紧急程度。
		/// </summary>
		/// <remarks>
		/// 通知的紧急程度代码：1-常规，2-紧急，4-特急。默认为常规（1）。
		/// </remarks>
		[global::Pittypat.Parameter(9)]
		public @int8? Urgency { get; set; }

		/// <summary>
		/// 获取或者设置分组。
		/// </summary>
		/// <remarks>
		/// 通知隶属的分组。
		/// </remarks>
		[global::Pittypat.Parameter(10, MaxLength = 30)]
		public @string? Group { get; set; }

		/// <summary>
		/// 获取或者设置起始接收时间。
		/// </summary>
		/// <remarks>
		/// 消息的接收时间。
		/// </remarks>
		[global::Pittypat.Parameter(11)]
		public @datetime? ReceiveTimeFrom { get; set; }

		/// <summary>
		/// 获取或者设置截至接收时间。
		/// </summary>
		/// <remarks>
		/// 消息的接收时间。
		/// </remarks>
		[global::Pittypat.Parameter(12)]
		public @datetime? ReceiveTimeTo { get; set; }

		/// <summary>
		/// 获取或者设置是否包含置顶通知。
		/// </summary>
		/// <remarks>
		/// 指示是否同时查询置顶的通知消息。
		/// </remarks>
		[global::Pittypat.Parameter(13)]
		public @bool? IncludesTop { get; set; }

		/// <summary>
		/// 获取或者设置未置顶通知列表。
		/// </summary>
		/// <remarks>
		/// 满足条件的未置顶通知列表。
		/// </remarks>
		[global::Pittypat.Parameter(14, Direction = global::Pittypat.ParameterDirection.Out)]
		public global::Pittypat.DataList<global::Waln.Notifying.Inbox.Data.Notification> Notifications { get; set; }

		/// <summary>
		/// 获取或者设置置顶通知列表。
		/// </summary>
		/// <remarks>
		/// 已经被用户置顶的通知消息的列表。置顶通知列表不会进行分页。
		/// </remarks>
		[global::Pittypat.Parameter(15, Direction = global::Pittypat.ParameterDirection.Out)]
		public global::Pittypat.DataList<global::Waln.Notifying.Inbox.Data.Notification> TopNotifications { get; set; }

		/// <summary>
		/// 获取或者设置指定名称的参数值。
		/// </summary>
		/// <param name="name">参数名称，不区分大小写。</param>
		/// <returns>目标名称的参数值。如果参数不存在，则返回 null。</returns>
		/// <exception cref="global::System.ArgumentException">设置参数值时发现参数不存在。</exception>
		public override object this[string name]
		{
			get
			{
				if (string.IsNullOrEmpty(name))
				{
					return null;
				}

				switch (name.ToLower())
				{
					case "pageindex":
						return this.PageIndex;
					case "pagesize":
						return this.PageSize;
					case "totalrows":
						return this.TotalRows;
					case "ordername":
						return this.OrderName;
					case "orderdirection":
						return this.OrderDirection;
					case "userid":
						return this.UserId;
					case "title":
						return this.Title;
					case "sendername":
						return this.SenderName;
					case "isread":
						return this.IsRead;
					case "urgency":
						return this.Urgency;
					case "group":
						return this.Group;
					case "receivetimefrom":
						return this.ReceiveTimeFrom;
					case "receivetimeto":
						return this.ReceiveTimeTo;
					case "includestop":
						return this.IncludesTop;
					case "notifications":
						return this.Notifications;
					case "topnotifications":
						return this.TopNotifications;
					default:
						return null;
				}
			}
			set
			{
				if (string.IsNullOrEmpty(name))
				{
					throw new global::System.ArgumentException("没有提供有效的参数名称。", "name");
				}

				switch (name.ToLower())
				{
					case "pageindex":
						this.PageIndex = (@int64?)value;
						break;
					case "pagesize":
						this.PageSize = (@int64?)value;
						break;
					case "totalrows":
						this.TotalRows = (@int64?)value;
						break;
					case "ordername":
						this.OrderName = (@string?)value;
						break;
					case "orderdirection":
						this.OrderDirection = (@string?)value;
						break;
					case "userid":
						this.UserId = (@uuid?)value;
						break;
					case "title":
						this.Title = (@string?)value;
						break;
					case "sendername":
						this.SenderName = (@string?)value;
						break;
					case "isread":
						this.IsRead = (@bool?)value;
						break;
					case "urgency":
						this.Urgency = (@int8?)value;
						break;
					case "group":
						this.Group = (@string?)value;
						break;
					case "receivetimefrom":
						this.ReceiveTimeFrom = (@datetime?)value;
						break;
					case "receivetimeto":
						this.ReceiveTimeTo = (@datetime?)value;
						break;
					case "includestop":
						this.IncludesTop = (@bool?)value;
						break;
					case "notifications":
						this.Notifications = (global::Pittypat.DataList<global::Waln.Notifying.Inbox.Data.Notification>)value;
						break;
					case "topnotifications":
						this.TopNotifications = (global::Pittypat.DataList<global::Waln.Notifying.Inbox.Data.Notification>)value;
						break;
					default:
						throw new global::System.ArgumentException(name + " 不是 " + this.GetType().Name + " 的有效参数名称。", "name");
				}
			}
		}

		#endregion

		#region 方法

		/// <summary>
		/// 将当前对象作为 JSON 字符串写入指定的文本流。
		/// </summary>
		/// <param name="writer">目标文本流。</param>
		/// <exception cref="global::System.ArgumentNullException">writer 是 null。</exception>
		public override void Write(global::System.IO.TextWriter writer)
		{
			if (writer == null)
			{
				throw new global::System.ArgumentNullException("writer");
			}

			writer.Write('{');

			// 页码
			writer.Write("\"pageIndex\":");
			this.PageIndex.Write(writer);
			writer.Write(',');

			// 页面尺寸
			writer.Write("\"pageSize\":");
			this.PageSize.Write(writer);
			writer.Write(',');

			// 总行数
			writer.Write("\"totalRows\":");
			this.TotalRows.Write(writer);
			writer.Write(',');

			// 排序名称
			writer.Write("\"orderName\":");
			this.OrderName.Write(writer);
			writer.Write(',');

			// 排序方向
			writer.Write("\"orderDirection\":");
			this.OrderDirection.Write(writer);
			writer.Write(',');

			// 用户 Id
			writer.Write("\"userId\":");
			this.UserId.Write(writer);
			writer.Write(',');

			// 通知标题
			writer.Write("\"title\":");
			this.Title.Write(writer);
			writer.Write(',');

			// 发送人名称
			writer.Write("\"senderName\":");
			this.SenderName.Write(writer);
			writer.Write(',');

			// 是否已读
			writer.Write("\"isRead\":");
			this.IsRead.Write(writer);
			writer.Write(',');

			// 紧急程度
			writer.Write("\"urgency\":");
			this.Urgency.Write(writer);
			writer.Write(',');

			// 分组
			writer.Write("\"group\":");
			this.Group.Write(writer);
			writer.Write(',');

			// 起始接收时间
			writer.Write("\"receiveTimeFrom\":");
			this.ReceiveTimeFrom.Write(writer);
			writer.Write(',');

			// 截至接收时间
			writer.Write("\"receiveTimeTo\":");
			this.ReceiveTimeTo.Write(writer);
			writer.Write(',');

			// 是否包含置顶通知
			writer.Write("\"includesTop\":");
			this.IncludesTop.Write(writer);
			writer.Write(',');

			// 未置顶通知列表
			writer.Write("\"notifications\":");
			if (this.Notifications == null)
			{
				writer.Write("null");
			}
			else
			{
				this.Notifications.Write(writer);
			}
			writer.Write(',');

			// 置顶通知列表
			writer.Write("\"topNotifications\":");
			if (this.TopNotifications == null)
			{
				writer.Write("null");
			}
			else
			{
				this.TopNotifications.Write(writer);
			}

			writer.Write('}');
		}

		#endregion
	}
}
